<?php

namespace App\Store\Validate\Order;

use App\Common\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class OrderPointschangebalance extends BaseValidate
{

    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];


    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
               // 'mobile' => ['required', 'regex:/^1[3-9]\d{9}$/'],
                'mobile'=> ['required'],
                'money'=>'required|integer|gt:0',
                'points'=>'required|integer|gt:0',

//                'shopping_account_id1'=>'required|integer|gt:0',
                // 'shopping_account_id2'=>'required|integer|gt:0',
//                'classesset_id'=>'required|integer|gt:0',
                // 'order_at'=>'required',
                // 'issendpoints'=>'required|in:1,2',
            ];
            $this->message = [
                'mobile.required' => '手机号码不能为空',
               //'mobile.regex'=>'手机号码不规范',
                'money.required' => '预存金额不能为空',
                'money.integer' => '预存金额需大于0',
                'money.gt' => '预存金额需大于0',
                'points.required' => '所需积分不能为空',
                'points.integer' => '所需积分需大于等于0',
                'points.gt' => '所需积分需大于等于0',
                'issendpoints.required' => '是否产生积分未选择',
                'issendpoints.in' => '是否产生积分参数错误',
            ];
        } elseif ($doaction == 'edit') {
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'money'=>'required|integer|gt:0',
                'points'=>'required|integer|gt:0',

                'shopping_account_id1'=>'required|integer|gt:0',
                'shopping_account_id2'=>'required|integer|gt:0',
//                'classesset_id'=>'required|integer|gt:0',
                'order_at'=>'required',
                'issendpoints'=>'required|in:1,2',
            ];
            $this->message = [
                'id.required' => '参数错误',
                'id.integer' => '参数错误',
                'id.gt' => '参数错误',
                'money.required' => '预存金额不能为空',
                'money.integer' => '预存金额需大于0',
                'money.gt' => '预存金额需大于0',
                'points.required' => '所需积分不能为空',
                'points.integer' => '所需积分需大于等于0',
                'points.gt' => '所需积分需大于等于0',
                'shopping_account_id1.required' => '导购未选择',
                'shopping_account_id1.integer' => '导购参数错误',
                'shopping_account_id1.gt' => '导购参数错误',
                'shopping_account_id2.required' => '副导购未选择',
                'shopping_account_id2.integer' => '副导购参数错误',
                'shopping_account_id2.gt' => '副导购参数错误',
                'classesset_id.required' => '班次未选择',
                'classesset_id.integer' => '班次参数错误',
                'classesset_id.gt' => '班次参数错误',
                'order_at.required' => '下单时间未选择',
                'issendpoints.required' => '是否产生积分未选择',
                'issendpoints.in' => '是否产生积分参数错误',
            ];
        }
    }
}
